﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SpiderHelper.Tools.MMOnly
{
    /// <summary>
    /// 对http://www.mmonly.com 进行访问
    /// </summary>
    public class MMVisitor
    {
        internal static readonly string URL = "http://www.mmonly.com/";
        internal static readonly string encode = "gb2312";

        public List<Model.TempDoc> ReadMMOnly(Model.CollectionChannel channel, DavidDB.ADO.DBManager db)
        {
            ChannelRead cread = new ChannelRead();
            List<Model.TempDoc> docs = new List<Model.TempDoc>();

            List<RohonModels.Models.Album> albums = cread.Read(channel.ChannelURL, false);
            foreach (RohonModels.Models.Album album in albums)
            {
                Model.TempDoc doc = new Model.TempDoc();
                doc.Author = "";
                doc.ChannelId = channel.Id;
                doc.Content = "";//
                doc.Description = "";

                AlbumRead aread = new AlbumRead(album);

                string nexturl = "nexturl";
                while (!string.IsNullOrEmpty(nexturl))
                {
                    string img = "";
                    nexturl = aread.Read(nexturl.Equals("nexturl") ? album.Url : nexturl, false, out img);
                    doc.Content += img;
                }

                doc.Link = album.Url;
                doc.Pdate = DateTime.Now;
                doc.SiteId = 3;
                doc.Sured = 0;
                doc.Title = album.Name;
                docs.Add(doc);
            }
            return docs;
        }





    }
}
